<template>
  <div class="login">
      <div class="handBg">
          <img src="../../assets/image/loginbg.gif" />
      </div>
      <div class="loginFrom">
          <div class="fromInfo">
            <el-form v-model="userInfo" status-icon label-width="100px">
                <div class="fromTitle">后台管理</div>
                <el-form-item label="账号/手机号">
                    <el-input type="text" v-model="loginFromInt.userPhone" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="密码">
                    <el-input type="password" v-model="loginFromInt.passWord" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item style="text-aline: center">
                    <el-button style="width:100%" type="primary" plain @click="submitForm()">登录</el-button>
                </el-form-item>
            </el-form>
          </div>
      </div>
  </div>
</template>

<script lang="ts">
import router from '@/router';
import { ElMessage } from 'element-plus';
import { defineComponent, reactive, toRefs } from 'vue';
import {initData} from '../../types/login';

export default defineComponent({
    setup () {
        const data = reactive(new initData)
        // 登录验证
        const submitForm = ()=> {
            if(data.loginFromInt.userPhone == '') {
                ElMessage({
                    message: '请输入手机号',
                    type: 'warning',
                })
            }else if(data.loginFromInt.passWord == '') {
                ElMessage({
                    message: '请输入密码',
                    type: 'warning',
                })
            }else {
                ElMessage({
                    message: '登录成功',
                    type: 'success',
                })
                router.push('/statistics')
            }
        }
        return {
            ...toRefs(data),
            submitForm
        }
    }
});
</script>

<style scoped>
    .login {
        background: #000;
        height: 100vh;
        width: 100%;
    }
    .handBg {
        text-align: center;
    }
    .handBg img {
        width: 560px;
        height: 180px;
    }
    .fromInfo {
        background: rgb(255, 255, 255);
        padding: 10px 60px;
        margin: 10px auto;
        width: 30%;
        border-radius: 20px;
    }
    .fromTitle {
        text-align: center;
        padding: 20px 0;
    }
</style>

function submitForm() {
  throw new Error('Function not implemented.');
}

function submitForm() {
  throw new Error('Function not implemented.');
}
